/**
 * Created by Tim on 2018/1/4.
 */
function IsPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone",
        "SymbianOS", "Windows Phone",
        "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}


(function(){
    var orientLayer = document.getElementById("orientLayer");
    //判断横屏竖屏
    function checkDirect() {
        if (document.documentElement.clientHeight >= document.documentElement.clientWidth) {
            return "portrait";
        } else {
            return "landscape";
        }
    }
    //显示屏幕方向提示浮层
    function orientNotice() {
        var orient = checkDirect();
        if (orient == "portrait") {
            orientLayer.style.display = "none";
        } else {
            orientLayer.style.display = "block";
        }
    }
    function init() {
        if (!IsPC() || window.parent.length) {
            orientNotice();
            window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function () {
                setTimeout(orientNotice, 200);
            })
        } else {
            $('.phone-frame').addClass('pc')
        }
    }
    init();
})();

(function () {
    var valueP = {
        month: [1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18, 21, 24, 30, 36, 42, 48, 54, 60, 66, 72],
        boy_weight_p3: [3.98, 5.00, 5.95, 6.45, 6.82, 7.28, 7.68, 8.13, 8.53, 9.20, 9.80, 10.30, 11.00, 11.80, 12.50, 13.60, 14.70, 15.10, 15.96, 16.95, 18.21],
        boy_weight_p10: [4.21, 5.35, 6.21, 6.87, 7.33, 7.70, 8.30, 8.60, 9.06, 9.80, 10.25, 10.95, 11.60, 12.60, 13.60, 14.30, 15.50, 16.34, 17.15, 18.00, 19.40],
        boy_weight_p20: [4.40, 5.65, 6.50, 7.16, 7.60, 8.01, 8.60, 9.00, 9.40, 10.14, 10.60, 11.45, 12.00, 13.20, 14.18, 15.00, 16.10, 17.00, 18.05, 19.05, 20.66],
        boy_weight_p50: [4.90, 6.19, 7.12, 7.85, 8.25, 8.80, 9.34, 9.90, 10.29, 11.10, 11.45, 12.40, 13.10, 14.20, 15.50, 16.40, 17.75, 18.90, 20.06, 21.10, 23.50],
        boy_weight_p80: [5.45, 6.77, 7.75, 8.60, 9.05, 9.70, 10.02, 10.80, 11.30, 12.01, 12.55, 13.60, 14.30, 15.50, 17.00, 18.30, 19.82, 21.50, 23.15, 24.24, 27.45],
        boy_weight_p97: [6.30, 7.80, 8.60, 9.70, 10.40, 10.74, 11.36, 11.95, 12.80, 13.25, 13.85, 15.20, 16.35, 18.20, 20.15, 21.30, 23.90, 25.90, 29.00, 30.10, 33.70],
        boy_height_p3: [52.50, 56.40, 60.20, 62.10, 63.80, 65.50, 68.10, 70.10, 72.80, 76.50, 79.00, 81.50, 85.20, 89.30, 93.00, 96.40, 100.30, 103.60, 105.30, 108.40, 112.20],
        boy_height_p10: [53.50, 57.50, 61.00, 63.30, 65.20, 66.50, 69.50, 71.60, 74.50, 78.20, 80.30, 83.80, 86.60, 91.30, 95.30, 98.40, 102.60, 105.50, 108.50, 110.80, 116.10],
        boy_height_p20: [54.40, 58.50, 62.00, 64.10, 66.00, 67.70, 70.50, 73.00, 75.50, 79.50, 81.70, 85.00, 88.00, 93.30, 96.80, 100.00, 104.20, 107.20, 110.70, 113.20, 118.10],
        boy_height_p50: [56.00, 60.30, 63.50, 66.00, 67.50, 69.50, 73.00, 75.20, 77.60, 81.40, 83.80, 87.95, 90.50, 95.60, 99.60, 103.30, 107.70, 110.60, 114.30, 117.30, 122.50],
        boy_height_p80: [58.00, 62.00, 65.20, 67.60, 69.60, 71.20, 74.60, 77.30, 80.00, 83.60, 86.10, 90.40, 93.60, 98.10, 102.70, 106.50, 110.90, 114.70, 118.60, 120.70, 126.50],
        boy_height_p97: [60.50, 64.00, 67.30, 69.50, 72.00, 74.00, 76.70, 79.40, 83.50, 86.90, 89.00, 93.50, 97.00, 101.90, 107.60, 110.40, 115.40, 119.20, 123.60, 125.50, 132.40],
        girl_weight_p3: [3.66, 4.70, 5.40, 6.00, 6.31, 6.60, 7.24, 7.55, 8.20, 8.50, 9.05, 9.90, 10.30, 11.15, 12.20, 13.00, 13.85, 14.60, 15.70, 16.15, 17.23],
        girl_weight_p10: [3.95, 5.00, 5.78, 6.40, 6.70, 7.00, 7.70, 8.27, 8.55, 9.10, 9.65, 10.40, 10.95, 12.00, 13.05, 14.01, 14.70, 15.50, 16.60, 17.50, 18.62],
        girl_weight_p20: [4.11, 5.20, 6.00, 6.65, 6.99, 7.30, 8.00, 8.60, 8.87, 9.48, 10.00, 10.85, 11.40, 12.45, 13.60, 14.50, 15.40, 16.20, 17.50, 18.58, 19.40],
        girl_weight_p50: [4.56, 5.68, 6.55, 7.20, 7.60, 8.05, 8.80, 9.30, 9.75, 10.35, 10.82, 11.75, 12.50, 13.50, 14.90, 15.95, 17.03, 18.00, 19.30, 20.40, 22.00],
        girl_weight_p80: [5.10, 6.30, 7.24, 7.90, 8.38, 8.84, 9.63, 10.17, 10.70, 11.38, 11.88, 12.80, 13.70, 15.02, 16.37, 17.66, 18.95, 20.30, 21.70, 23.35, 25.30],
        girl_weight_p97: [5.81, 7.15, 8.00, 8.75, 9.50, 9.90, 10.62, 11.50, 12.05, 12.66, 13.35, 14.40, 15.91, 17.37, 19.08, 20.80, 23.00, 23.42, 25.10, 27.30, 30.10],
        girl_height_p3: [51.80, 55.50, 58.40, 60.20, 62.00, 63.80, 66.80, 68.80, 71.80, 75.00, 77.30, 80.80, 83.10, 88.10, 92.50, 95.50, 98.70, 101.20, 105.50, 108.30, 112.00],
        girl_height_p10: [52.60, 56.30, 59.30, 61.20, 63.70, 64.90, 68.20, 70.70, 73.00, 76.50, 79.10, 82.30, 85.20, 89.90, 94.50, 97.30, 100.60, 103.60, 108.00, 110.75, 114.40],
        girl_height_p20: [53.40, 57.15, 60.20, 62.50, 64.50, 65.80, 69.10, 71.80, 74.20, 77.80, 80.20, 83.90, 86.60, 91.20, 95.80, 99.50, 102.60, 105.60, 109.80, 112.70, 116.40],
        girl_height_p50: [55.00, 58.70, 61.80, 64.10, 66.00, 67.80, 71.10, 74.00, 76.30, 80.20, 82.40, 86.10, 89.00, 94.10, 98.90, 102.60, 106.00, 109.50, 113.20, 116.50, 120.80],
        girl_height_p80: [57.10, 60.50, 63.70, 66.00, 68.00, 69.50, 73.10, 75.90, 78.50, 82.50, 85.00, 88.40, 92.00, 96.75, 101.50, 105.70, 109.70, 112.70, 116.70, 120.50, 125.30],
        girl_height_p97: [59.60, 62.60, 66.00, 68.00, 69.90, 72.10, 75.60, 78.30, 81.60, 85.70, 87.70, 92.50, 95.20, 100.00, 106.20, 110.40, 114.00, 117.30, 121.70, 125.00, 130.00],
    };
    var BMI = {
        boy_height: [52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126],
        boy_weight_p3: [3.45, 3.80, 4.20, 4.20, 4.50, 4.80, 5.10, 5.35, 5.50, 5.84, 6.20, 6.20, 6.40, 6.90, 7.03, 7.14, 7.39, 7.70, 7.95, 7.99, 8.30, 8.46, 8.60, 8.80, 9.00, 9.23, 9.30, 9.50, 9.80, 10.00, 10.20, 10.20, 10.30, 10.35, 10.35, 10.95, 11.10, 11.25, 11.40, 11.70, 12.23, 12.30, 12.35, 12.57, 13.00, 13.10, 13.55, 13.71, 13.85, 14.11, 14.16, 14.20, 14.75, 14.80, 14.93, 15.35, 15.60, 15.86, 16.32, 16.80, 16.85, 16.91, 17.20, 17.40, 18.00, 18.25, 18.32, 18.50, 18.75, 19.35, 19.65, 20.20, 20.25, 21.40, 21.50],
        boy_weight_p10: [3.75, 4.10, 4.24, 4.42, 4.82, 5.05, 5.31, 5.55, 5.80, 6.08, 6.40, 6.55, 6.76, 7.20, 7.34, 7.52, 7.76, 8.20, 8.30, 8.44, 8.60, 8.77, 8.99, 9.10, 9.27, 9.40, 9.70, 9.80, 10.10, 10.27, 10.48, 10.78, 10.90, 10.95, 11.10, 11.40, 11.75, 11.92, 11.94, 12.50, 12.65, 12.80, 12.85, 13.10, 13.51, 13.83, 13.90, 14.00, 14.20, 14.35, 14.55, 14.98, 15.20, 15.22, 15.80, 16.00, 16.60, 16.75, 17.20, 17.48, 17.85, 17.90, 18.20, 18.40, 18.60, 18.80, 19.25, 19.35, 19.60, 20.39, 20.70, 21.58, 22.05, 22.10, 22.30],
        boy_weight_p20: [4.05, 4.15, 4.33, 4.56, 5.00, 5.19, 5.50, 5.81, 6.00, 6.33, 6.59, 6.80, 7.06, 7.45, 7.60, 7.71, 7.98, 8.32, 8.48, 8.70, 8.90, 9.02, 9.20, 9.40, 9.60, 9.81, 10.00, 10.10, 10.35, 10.41, 10.83, 11.00, 11.24, 11.30, 11.46, 11.81, 11.92, 12.14, 12.30, 12.85, 13.00, 13.15, 13.15, 13.35, 13.90, 14.00, 14.15, 14.60, 14.77, 15.24, 15.35, 15.50, 15.80, 15.90, 16.20, 16.51, 17.05, 17.20, 17.48, 18.01, 18.25, 18.40, 18.90, 19.29, 19.53, 19.60, 20.20, 20.45, 20.80, 21.50, 21.80, 22.61, 22.68, 22.75, 23.11],
        boy_weight_p50: [4.35, 4.57, 4.70, 4.90, 5.25, 5.62, 5.88, 6.15, 6.45, 6.75, 7.07, 7.35, 7.50, 8.00, 8.05, 8.38, 8.57, 8.90, 9.14, 9.30, 9.40, 9.64, 9.87, 10.10, 10.23, 10.30, 10.50, 10.78, 11.00, 11.05, 11.40, 11.50, 11.90, 12.03, 12.20, 12.64, 12.70, 13.05, 13.20, 13.35, 13.53, 13.80, 13.99, 14.04, 14.60, 14.90, 15.10, 15.45, 15.80, 15.90, 16.20, 16.63, 16.68, 16.84, 17.20, 17.55, 18.15, 18.20, 18.80, 19.01, 19.50, 19.60, 19.90, 20.98, 21.24, 21.65, 21.80, 22.25, 23.31, 23.40, 23.70, 24.20, 24.60, 24.70, 24.80],
        boy_weight_p80: [4.60, 4.90, 5.00, 5.25, 5.74, 6.00, 6.40, 6.50, 7.00, 7.25, 7.69, 8.00, 8.10, 8.50, 8.65, 8.93, 9.20, 9.75, 9.80, 9.90, 10.00, 10.45, 10.75, 10.75, 11.03, 11.20, 11.30, 11.50, 12.00, 12.00, 12.03, 12.05, 12.58, 12.72, 12.80, 13.50, 13.58, 13.80, 14.15, 14.35, 14.60, 14.70, 15.05, 15.42, 15.65, 15.80, 15.95, 16.20, 16.85, 16.90, 17.67, 18.10, 18.15, 18.36, 18.54, 18.90, 19.64, 20.00, 20.50, 20.75, 20.85, 21.40, 21.76, 22.70, 22.86, 23.20, 23.72, 24.15, 24.50, 26.20, 26.60, 27.44, 27.50, 27.60, 28.78],
        boy_weight_p97: [4.98, 5.20, 5.64, 5.85, 6.40, 6.55, 6.70, 7.25, 7.50, 8.00, 8.30, 8.80, 9.00, 9.24, 9.65, 10.10, 10.23, 10.45, 10.64, 10.87, 11.10, 11.38, 11.50, 11.76, 12.05, 12.30, 12.40, 12.56, 12.60, 12.65, 12.95, 13.10, 14.00, 14.15, 14.36, 14.50, 14.70, 14.81, 15.20, 15.80, 15.90, 16.15, 16.68, 17.60, 18.00, 18.20, 18.40, 18.60, 18.80, 19.20, 20.00, 20.50, 21.00, 21.15, 21.23, 21.60, 21.73, 22.52, 23.90, 24.00, 24.12, 24.65, 24.90, 26.78, 27.38, 29.20, 29.25, 29.28, 30.50, 30.90, 31.95, 32.20, 32.70, 32.85, 33.20],
        girl_height: [51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124],
        girl_weight_p3: [3.50, 3.62, 3.72, 3.96, 4.19, 4.50, 4.65, 4.95, 5.40, 5.40, 5.70, 6.10, 6.20, 6.50, 6.50, 6.93, 7.00, 7.17, 7.45, 7.55, 7.65, 7.78, 7.90, 8.25, 8.50, 8.65, 8.76, 9.00, 9.20, 9.35, 9.75, 9.80, 10.00, 10.05, 10.20, 10.30, 10.60, 11.20, 11.25, 11.35, 11.50, 11.75, 12.00, 12.10, 12.25, 12.58, 12.68, 12.86, 13.20, 13.40, 13.70, 13.75, 13.80, 14.15, 14.20, 14.50, 14.84, 15.45, 15.50, 15.85, 15.95, 16.60, 16.70, 16.90, 17.22, 17.30, 17.59, 17.72, 18.25, 18.90, 19.30, 19.38, 19.40, 20.56],
        girl_weight_p10: [3.62, 3.80, 3.95, 4.10, 4.40, 4.75, 4.90, 5.20, 5.55, 5.75, 6.00, 6.26, 6.42, 6.80, 6.90, 7.22, 7.40, 7.49, 7.70, 8.00, 8.20, 8.40, 8.50, 8.60, 8.80, 9.05, 9.10, 9.25, 9.50, 9.64, 10.00, 10.05, 10.35, 10.50, 10.75, 10.80, 11.10, 11.40, 11.60, 11.70, 12.00, 12.15, 12.35, 12.45, 12.55, 13.00, 13.18, 13.60, 14.00, 14.10, 14.26, 14.35, 14.37, 15.10, 15.20, 15.24, 15.45, 15.90, 16.05, 16.40, 16.60, 17.23, 17.70, 17.72, 18.25, 18.70, 18.70, 19.20, 19.30, 19.35, 19.94, 20.22, 21.35, 21.55],
        girl_weight_p20: [3.81, 3.95, 4.10, 4.33, 4.55, 4.85, 5.09, 5.30, 5.70, 5.95, 6.13, 6.50, 6.65, 6.95, 7.10, 7.45, 7.60, 7.75, 8.00, 8.20, 8.45, 8.60, 8.75, 8.80, 9.10, 9.25, 9.45, 9.50, 9.80, 9.90, 10.24, 10.50, 10.60, 10.90, 11.10, 11.10, 11.45, 11.80, 12.00, 12.30, 12.35, 12.85, 12.85, 12.90, 13.03, 13.45, 13.55, 13.95, 14.35, 14.55, 14.80, 14.80, 14.88, 15.44, 15.80, 15.90, 16.15, 16.30, 16.70, 17.20, 17.50, 17.93, 18.15, 18.40, 18.86, 19.30, 19.50, 19.83, 20.10, 20.21, 20.60, 21.65, 21.71, 21.74],
        girl_weight_p50: [4.00, 4.25, 4.35, 4.60, 4.95, 5.20, 5.50, 5.80, 6.15, 6.37, 6.65, 6.91, 7.12, 7.35, 7.50, 7.93, 8.20, 8.35, 8.60, 8.75, 8.95, 9.10, 9.30, 9.58, 9.70, 9.90, 9.95, 10.20, 10.35, 10.50, 10.70, 11.18, 11.20, 11.49, 11.80, 11.80, 12.13, 12.40, 12.70, 13.13, 13.23, 13.50, 13.50, 13.65, 13.75, 14.50, 14.70, 14.70, 15.40, 15.50, 15.73, 15.81, 16.00, 16.40, 16.57, 16.88, 17.53, 17.69, 17.94, 18.40, 18.82, 19.01, 19.40, 19.84, 20.32, 20.67, 20.70, 21.50, 21.70, 21.90, 22.28, 23.18, 23.71, 23.90],
        girl_weight_p80: [4.23, 4.48, 4.66, 4.98, 5.30, 5.51, 5.97, 6.30, 6.60, 6.88, 7.13, 7.40, 7.60, 7.91, 8.05, 8.50, 8.88, 9.00, 9.15, 9.35, 9.50, 9.80, 10.00, 10.20, 10.36, 10.50, 10.55, 10.90, 11.12, 11.35, 11.39, 12.10, 12.15, 12.20, 12.50, 12.70, 13.00, 13.20, 13.50, 13.93, 13.95, 14.30, 14.35, 14.90, 15.03, 15.52, 15.79, 15.87, 16.20, 16.80, 16.85, 17.00, 17.40, 17.70, 17.75, 18.20, 19.39, 19.46, 20.00, 20.06, 20.15, 20.20, 20.80, 21.07, 22.40, 22.98, 23.00, 23.10, 24.70, 24.80, 24.90, 24.90, 25.05, 25.90],
        girl_weight_p97: [4.75, 4.87, 4.92, 5.55, 5.65, 6.40, 6.90, 6.95, 7.10, 7.84, 7.90, 8.25, 8.50, 8.70, 8.90, 9.50, 9.60, 9.70, 10.00, 10.58, 10.70, 10.78, 11.20, 11.25, 11.32, 11.67, 11.73, 11.75, 12.10, 12.35, 12.55, 12.75, 12.80, 12.85, 13.70, 14.00, 14.30, 14.95, 15.07, 15.15, 15.25, 15.45, 15.70, 16.95, 17.05, 17.37, 17.70, 18.15, 18.40, 18.75, 19.00, 19.30, 19.40, 19.50, 20.50, 20.50, 21.20, 22.00, 22.49, 22.69, 22.80, 22.90, 24.60, 24.65, 24.86, 25.10, 25.50, 26.09, 27.91, 28.00, 28.03, 28.35, 28.80, 29.00],
    };

    var BMI2 = {
        height: [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],
        boy_sd0: [2.4, 2.6, 2.8, 2.9, 3.1, 3.3, 3.5, 3.8, 4, 4.3, 4.5, 4.8, 5.1, 5.4, 5.7, 6, 6.3, 6.5, 6.8, 7, 7.3, 7.5, 7.7, 8, 8.2, 8.4, 8.6, 8.9, 9.1, 9.3, 9.5, 9.7, 9.9, 10.1, 10.3, 10.4, 10.6, 10.8, 11, 11.3, 11.5, 11.7, 12, 12.2, 12.5, 12.7, 13, 13.2, 13.4, 13.7, 13.9, 14.1, 14.4, 14.6, 14.9, 15.2, 15.4, 15.7, 16, 16.3, 16.6, 16.9, 17.3, 17.6, 17.9, 18.3],
        boy_sd1: [2.7, 2.9, 3, 3.2, 3.4, 3.6, 3.9, 4.1, 4.4, 4.7, 5, 5.3, 5.6, 5.9, 6.2, 6.5, 6.8, 7.1, 7.4, 7.6, 7.9, 8.2, 8.4, 8.7, 8.9, 9.2, 9.4, 9.6, 9.9, 10.1, 10.3, 10.6, 10.8, 11, 11.2, 11.4, 11.6, 11.8, 12, 12.2, 12.5, 12.8, 13, 13.3, 13.5, 13.8, 14.1, 14.3, 14.6, 14.8, 15.1, 15.3, 15.6, 15.9, 16.2, 16.5, 16.8, 17.1, 17.4, 17.8, 18.1, 18.5, 18.8, 19.2, 19.6, 20],
        boy_sd2: [3, 3.1, 3.3, 3.6, 3.8, 4, 4.2, 4.5, 4.8, 5.1, 5.4, 5.8, 6.1, 6.4, 6.8, 7.1, 7.4, 7.7, 8, 8.3, 8.6, 8.9, 9.2, 9.4, 9.7, 10, 10.2, 10.5, 10.8, 11, 11.3, 11.5, 11.7, 12, 12.2, 12.4, 12.6, 12.8, 13.1, 13.3, 13.6, 13.9, 14.2, 14.5, 14.7, 15, 15.3, 15.6, 15.8, 16.1, 16.4, 16.7, 17, 17.3, 17.6, 18, 18.3, 18.7, 19, 19.4, 19.8, 20.2, 20.6, 21, 21.4, 21.9],
        boy_sd3: [3.3, 3.5, 3.7, 3.9, 4.2, 4.4, 4.7, 5, 5.3, 5.6, 6, 6.3, 6.7, 7.1, 7.4, 7.8, 8.1, 8.5, 8.8, 9.1, 9.4, 9.7, 10, 10.3, 10.6, 10.9, 11.2, 11.5, 11.8, 12.1, 12.3, 12.6, 12.8, 13.1, 13.3, 13.6, 13.8, 14, 14.3, 14.6, 14.9, 15.2, 15.5, 15.8, 16.1, 16.4, 16.7, 17, 17.3, 17.6, 17.9, 18.2, 18.5, 18.9, 19.2, 19.6, 20, 20.4, 20.8, 21.2, 21.7, 22.1, 22.6, 23.1, 23.6, 24.1],
        girl_sd0: [2.5, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8, 4, 4.3, 4.5, 4.8, 5.1, 5.4, 5.6, 5.9, 6.1, 6.4, 6.6, 6.9, 7.1, 7.3, 7.5, 7.7, 8, 8.2, 8.4, 8.6, 8.8, 9, 9.1, 9.3, 9.5, 9.7, 9.9, 10.1, 10.3, 10.5, 10.7, 11, 11.2, 11.5, 11.7, 12, 12.2, 12.5, 12.7, 13, 13.2, 13.5, 13.7, 14, 14.2, 14.5, 14.8, 15, 15.3, 15.6, 15.9, 16.2, 16.5, 16.9, 17.2, 17.6, 18, 18.3],
        girl_sd1: [2.7, 2.9, 3.1, 3.3, 3.5, 3.7, 3.9, 4.2, 4.4, 4.7, 5, 5.3, 5.6, 5.9, 6.2, 6.4, 6.7, 7, 7.3, 7.5, 7.8, 8, 8.3, 8.5, 8.7, 9, 9.2, 9.4, 9.6, 9.8, 10, 10.2, 10.4, 10.6, 10.8, 11, 11.3, 11.5, 11.8, 12, 12.3, 12.6, 12.8, 13.1, 13.4, 13.7, 13.9, 14.2, 14.5, 14.7, 15, 15.3, 15.6, 15.9, 16.2, 16.5, 16.8, 17.1, 17.5, 17.8, 18.2, 18.5, 18.9, 19.3, 19.7, 20.2],
        girl_sd2: [3, 3.2, 3.4, 3.6, 3.8, 4, 4.3, 4.6, 4.9, 5.2, 5.5, 5.8, 6.1, 6.5, 6.8, 7.1, 7.4, 7.7, 8, 8.3, 8.6, 8.8, 9.1, 9.4, 9.6, 9.9, 10.1, 10.3, 10.6, 10.8, 11, 11.2, 11.5, 11.7, 11.9, 12.1, 12.4, 12.6, 12.9, 13.2, 13.5, 13.8, 14.1, 14.4, 14.7, 15, 15.3, 15.6, 15.9, 16.2, 16.5, 16.8, 17.1, 17.5, 17.8, 18.1, 18.5, 18.9, 19.2, 19.6, 20, 20.5, 20.9, 21.3, 21.8, 22.3],
        girl_sd3: [3.3, 3.5, 3.7, 3.9, 4.2, 4.4, 4.7, 5, 5.3, 5.6, 6, 6.3, 6.7, 7.1, 7.4, 7.8, 8.1, 8.5, 8.8, 9.1, 9.4, 9.7, 10, 10.3, 10.6, 10.9, 11.2, 11.5, 11.8, 12.1, 12.3, 12.6, 12.8, 13.1, 13.3, 13.6, 13.8, 14, 14.3, 14.6, 14.9, 15.2, 15.5, 15.8, 16.1, 16.4, 16.7, 17, 17.3, 17.6, 17.9, 18.2, 18.5, 18.9, 19.2, 19.6, 20, 20.4, 20.8, 21.2, 21.7, 22.1, 22.6, 23.1, 23.6, 24.1],
    };

    var $pValue = $('.p-value');
    var name = $pValue.data('name');
    var gender = $pValue.data('gender');
    var height = $pValue.data('height');
    var weight = $pValue.data('weight');
    var month = $pValue.data('month');
    console.log(gender, height, weight, month);

    var valuePData = {
        boy_height_p3: [],
        boy_height_p10: [],
        boy_height_p20: [],
        boy_height_p50: [],
        boy_height_p80: [],
        boy_height_p97: [],
        girl_height_p3: [],
        girl_height_p10: [],
        girl_height_p20: [],
        girl_height_p50: [],
        girl_height_p80: [],
        girl_height_p97: [],
        boy_weight_p3: [],
        boy_weight_p10: [],
        boy_weight_p20: [],
        boy_weight_p50: [],
        boy_weight_p80: [],
        boy_weight_p97: [],
        girl_weight_p3: [],
        girl_weight_p10: [],
        girl_weight_p20: [],
        girl_weight_p50: [],
        girl_weight_p80: [],
        girl_weight_p97: []
    };

    var mon = valueP.month;

    function judgeValueP(month, gender, type, value, line, symbol) {

        for (i = 0; i < mon.length; i++) {
            if (month == mon[i]) {
                return eval(value + symbol + '(valueP.' + gender + '_' + type + '_p' + line + '[' + i + '])')
            }

            if (month < mon[i]) {
                var v = cal(mon[i - 1], eval('valueP.' + gender + '_' + type + '_p' + line + '[' + (i - 1) + ']'), mon[i], eval('valueP.' + gender + '_' + type + '_p' + line + '[' + i + ']'), month)
                return eval(value + symbol + v)
            }

        }

    }

    function cal(start_m, start_v, end_m, end_v, target_m) {

        return start_v + (end_v - start_v) / (end_m - start_m) * (target_m - start_m)

    }

    function judgeValueBMI(height, gender, weight, line, symbol) {
        var heightBMI = BMI[gender + '_height'];
        height = parseInt(height);
        for (i = 0; i < heightBMI.length; i++) {
            if (height == heightBMI[i]) {
                return eval(weight + symbol + '(BMI.' + gender + '_weight_p' + line + '[' + i + '])')
            }

        }
    }


    function judgeValueSD(height, gender, weight, line, symbol) {
        var heightX = BMI2.height;
        height = parseInt(height);
        for (i = 0; i < heightX.length; i++) {
            if (height == heightX[i]) {
                return eval(weight + symbol + '(BMI2.' + gender + '_sd' + line + '[' + i + '])')
            }

        }
    }

    var conclusion = '';
    var heightPercent = '';
    var weightPercent = '';
    var bmiPercent = '';

    if (judgeValueP(month, gender, 'height', height, 3, '<')) {
        heightPercent = '<P3';
    } else if (judgeValueP(month, gender, 'height', height, 10, '<')) {
        heightPercent = 'P3-P10';
    } else if (judgeValueP(month, gender, 'height', height, 20, '<')) {
        heightPercent = 'P10-P20';
    } else if (judgeValueP(month, gender, 'height', height, 50, '<')) {
        heightPercent = 'P2-P50';
    } else if (judgeValueP(month, gender, 'height', height, 80, '<')) {
        heightPercent = 'P50-P80';
    } else if (judgeValueP(month, gender, 'height', height, 97, '<')) {
        heightPercent = 'P80-P97';
    } else {
        heightPercent = '>P97';
    }

    if (judgeValueP(month, gender, 'weight', weight, 3, '<')) {
        weightPercent = '<P3';
    } else if (judgeValueP(month, gender, 'weight', weight, 10, '<')) {
        weightPercent = 'P3-P10';
    } else if (judgeValueP(month, gender, 'weight', weight, 20, '<')) {
        weightPercent = 'P10-P20';
    } else if (judgeValueP(month, gender, 'weight', weight, 50, '<')) {
        weightPercent = 'P2-P50';
    } else if (judgeValueP(month, gender, 'weight', weight, 80, '<')) {
        weightPercent = 'P50-P80';
    } else if (judgeValueP(month, gender, 'weight', weight, 97, '<')) {
        weightPercent = 'P80-P97';
    } else {
        weightPercent = '>P97';
    }

    if (judgeValueBMI(height, gender, weight, 3, '<')) {
        bmiPercent = '<P3';
    } else if (judgeValueBMI(height, gender, weight, 10, '<')) {
        bmiPercent = 'P3-P10';
    } else if (judgeValueBMI(height, gender, weight, 20, '<')) {
        bmiPercent = 'P10-P20';
    } else if (judgeValueBMI(height, gender, weight, 50, '<')) {
        bmiPercent = 'P2-P50';
    } else if (judgeValueBMI(height, gender, weight, 80, '<')) {
        bmiPercent = 'P50-P80';
    } else if (judgeValueBMI(height, gender, weight, 97, '<')) {
        bmiPercent = 'P80-P97';
    } else {
        bmiPercent = '>P97';
    }

    conclusion = '从上述三个图表可以看到' + name + '宝宝按年龄测身长的百分位数为' + heightPercent + '，按年龄测体重的百分位数为' + weightPercent + '，按身长测体重的百分位数为' + bmiPercent + '，综合上述三个数据可以得出' + name + '宝宝';

    if (judgeValueP(month, gender, 'weight', weight, 3, '<') && judgeValueBMI(height, gender, weight, 3, '<')) {
        conclusion += '为重度营养不良，需进一步调整饮食，增强锻炼。'
    } else if (judgeValueP(month, gender, 'weight', weight, 10, '<') && judgeValueBMI(height, gender, weight, 10, '<')) {
        conclusion += '为轻度营养不良，需进一步调整饮食，增强锻炼。'
    } else if (judgeValueP(month, gender, 'weight', weight, 50, '>=') && judgeValueBMI(height, gender, weight, 50, '>=')) {
        if (judgeValueSD(height, gender, weight, 3, '>=')) {
            conclusion += '为中重度肥胖，需进一步调整饮食，增强锻炼！'
        } else if (judgeValueSD(height, gender, weight, 2, '>=')) {
            conclusion += '为轻度肥胖，需进一步调整饮食，增强锻炼！'
        } else if (judgeValueSD(height, gender, weight, 1, '>=')) {
            conclusion += '为超重，需进一步调整饮食，增强锻炼！'
        }else{
            conclusion += '身体发育正常！'
        }
    } else {
        conclusion += '身体发育正常！'
    }
    $('#conclusion').text(conclusion);
})();



